package com.night.xjh.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.night.common.entity.xjh.HiddenTroubleType;
import com.night.xjh.mapper.HiddenTroubleTypeMapper;
import com.night.xjh.service.HiddenTroubleTypeService;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName: HiddenTroubleTypeServiceImpl
 * @Description: //TODO
 * @author: xjh
 * @date: 2022/10/21-16:38
 * @version: v1.0
 */
@Service
public class HiddenTroubleTypeServiceImpl implements HiddenTroubleTypeService {
    @Resource
    private HiddenTroubleTypeMapper hiddenTroubleTypeMapper;

    @Resource
    private RedisTemplate redisTemplate;
    public List<HiddenTroubleType> getAll() {
        List<HiddenTroubleType> redisType = (List<HiddenTroubleType>) redisTemplate.opsForValue().get("hiddenType-getAll");
        if (redisType != null)
            return redisType;
        List<HiddenTroubleType> list=hiddenTroubleTypeMapper.getAll();
        redisTemplate.opsForValue().set("hiddenType-getAll", list, 60, TimeUnit.SECONDS);
        return list;
    }

    public HiddenTroubleType getById(int id) {
        return hiddenTroubleTypeMapper.getById(id);
    }
}
